package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.api.ResultCode;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.ProductLifeRequest;
import com.ytjj.qmyx.admin.service.ProductForumService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 *
 * @Version: 1.0
 *
 * 生活馆 模块
 */
@RestController
@RequestMapping("/productForum")
public class ProductForumController {

    @Resource
    private ProductForumService productForumService;

    @PostMapping("/list")
    @OperLog(operModule = "生活馆管理", operDesc = "列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getProductLife(@RequestBody ProductLifeRequest productLifeRequest) {
        return CommonResult.success(productForumService.getProductLife(productLifeRequest));
    }

    @GetMapping("/removeForum")
    @OperLog(operModule = "生活馆管理", operDesc = "移除", operType = SysLogConstants.OPERATION_DELETE)
    public CommonResult removeForum(@RequestParam Integer id){
        return CommonResult.success(productForumService.removeForum(id));
    }

    @GetMapping("/updateSort")
    @OperLog(operModule = "生活馆管理", operDesc = "编辑排序", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateSort(@RequestParam Integer id, @RequestParam Integer sort) {
        return CommonResult.success(productForumService.updateSort(id, sort));
    }

    /**
     * @Description 获取品牌商商品列表
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("/getBrandShopProductList")
    @OperLog(operModule = "生活馆管理", operDesc = "获取品牌商商品列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getBrandShopProductList(@RequestParam("id") Integer id) {
        return CommonResult.success(productForumService.getBrandShopProductList(id));
    }

    /**
     * 查询品牌商对应的商品
     */
    @GetMapping("/getBrandProductsByBankerId")
    @OperLog(operModule = "生活馆管理", operDesc = "查询品牌商对应的商品", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getBrandProductsByBankerId(@RequestParam("bankerId") Integer bankerId,
                                                   @RequestParam(value = "productName", required = false) String productName,
                                                   @RequestParam(value = "id", required = false) Integer id) {
        return CommonResult.success(productForumService.getBrandProductsByBankerId(bankerId, productName, id));
    }

    /**
     * @Description 新增品牌商商品
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("/addBrandProduct")
    @OperLog(operModule = "生活馆管理", operDesc = "新增品牌商商品", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult addBrandProduct(@RequestParam("forumId") Integer forumId,
                                        @RequestParam("productId") Integer productId) {
        productForumService.addBrandProduct(forumId, productId);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    @GetMapping("/removeBankerProduct")
    @OperLog(operModule = "生活馆管理", operDesc = "移除品牌商商品", operType = SysLogConstants.OPERATION_DELETE)
    public CommonResult removeBankerProduct(Integer id) {
        productForumService.removeBankerProduct(id);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    @GetMapping("/updateBankerProductSort")
    @OperLog(operModule = "生活馆管理", operDesc = "编辑排序", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateBankerProductSort(Integer id, Integer sort) {
        productForumService.updateBankerProductSort(id, sort);
        return CommonResult.success(ResultCode.SUCCESS);
    }


}
